home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / RBBS.SLT < prev    next >
Text File  |  1990-10-12  |  6KB  |  207 lines

  1. //-----------------------------------------------------------
  2. // RBBS.SL? Automatic logging into an RBBS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS RBBS.
  6. //-----------------------------------------------------------
  7.  
  8. str thisBBStype[] = "RBBS"   // This BBS type.      
  9.    ,line    [80]             // General input line.
  10.                              // For the Global storage:
  11.    ,global   []="GLOBAL"     // Global script.
  12.    ,bbstype  []="BTYPE"      // BBS type.
  13. // ,short    []="SHORT"      // Short BBS name.
  14. // ,protocol []="CPROT"      // Current protocol.
  15. // ,conf     []="CONF"       // Current conference
  16. // ,prompt   []="PROMPT"     // Current command prompt.
  17.    ;     
  18.  
  19. int tol = 300                            // No activity for 1 minute
  20.    ,stat, tmark
  21.    ;
  22.  
  23. //-----------------------------------------------------------   
  24. // Script starts here.
  25. //-----------------------------------------------------------   
  26.  
  27. main()
  28. {
  29. int novice;                              // Novice indicator.
  30.  
  31. // Variables for tracking:
  32. int mo,        // More?
  33.     en,        // ENter to continue
  34.     ak,        // Any key to continue
  35.     sc,        // Scan for mail
  36.     cm,        // Main command.
  37.     rb,        // Read Bulletins
  38.     nv;        // Novice.
  39.  
  40. // Only if online.
  41.  
  42.   if (!carrier())  
  43.   { failtone();
  44.     status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  45.     return (-1);
  46.   }
  47.  
  48.   read (bbstype,line);                   // Get BBS type. 
  49.  
  50.   if (line != thisBBStype)  
  51.   { wrongBBS();                          // Doesn't match script!
  52.     return (-1);
  53.   }
  54.  
  55.   entry();                               // Updates colors & status bar. 
  56.   cputs ("^K^K^K");                      // Send a BREAK to stop that     
  57.                                          // stupid heading.
  58.   novice = 0;                            // Assume I'm an expert.
  59.  
  60. // Start looking for requests from RBBS.
  61.  
  62.   mo = track ("N,C,A>?",0);              // More?
  63.   en = track ("A)bort?",0);              // ENTER to continue
  64.   ak = track ("ontinue",0);              // Any key to continue
  65.   sc = track ("[Y],N)?",0);              // Scan for mail/bulletins
  66.   cm = track ("V,W,X>?",0);              // Main command.
  67.   rb = track (" none)?",0);              // Read Bulletins
  68.   nv = track ("────── ",0);              // If novice.
  69.  
  70.   tmark = timer_start (tol);             // Gimme half a minute.
  71.  
  72.   while ((stat=trig()) > 0)              // answer any questions.
  73.   { if (stat==nv)                        // Novice?
  74.       novice = 1;
  75.  
  76.     else if (stat==en || stat==mo        // ENTER to continue or MORE?
  77.          ||  stat==sc)                   // Scan for mail?
  78.       cputs ("N^M");                     // No thanks. 
  79.  
  80.     else if (stat==ak                    // Any Key to continue
  81.          ||  stat==rb)                   // Read Bulletins?
  82.       cputs ("^M");
  83.  
  84.     else if (stat==cm)                   // Command?
  85.     { if (novice)                        // Novice?
  86.       { novice=0;                        // No I'm not!
  87.         cputs ("X^M");                   // Tell him I'm an expert!
  88.       }
  89.       else  
  90.         break;                           // Done!
  91.     }
  92.   }
  93.   release();                             // Release timer & tracks.
  94.  
  95. // Time-out or carrier lost!
  96.  
  97.   if (stat < 0)
  98.   { failtone();                          // Play fail tone.
  99.     status_wind ("Logon failed!",20);
  100.     return (-1);
  101.   }
  102.  
  103.   cputs ("R S^M");
  104.   return(0);  
  105. }
  106.  
  107. //-----------------------------------------------------------
  108. // Wrong BBS type.
  109. //-----------------------------------------------------------
  110.  
  111. wrongBBS()
  112. {
  113. str help[48];
  114.  
  115.     failtone();                          // Alarm.    
  116.     help = "This script is for ";        // Catenate strings.
  117.     strcat (help,thisBBStype);
  118.     strcat (help," only!");
  119.     status_wind (help,20);               // Display message for 2 sec.
  120. }
  121.  
  122. //-----------------------------------------------------------
  123. // Play fail tone.
  124. //-----------------------------------------------------------
  125.  
  126. failtone()
  127. {
  128.   int n;
  129.   for (n=140; n > 10; n = 100*n/120) 
  130.   { tone(n*10,12);                       // Fail tone!!
  131.     terminal();                          // Process text.
  132.   }
  133. }
  134.  
  135. //-----------------------------------------------------------
  136. // Routine to update colors and status bar.
  137. //-----------------------------------------------------------
  138.  
  139. entry ()
  140. {
  141.   _back_color = 1;
  142.   _fore_color = 14;
  143.   update_term();
  144. }
  145.  
  146. //-----------------------------------------------------------
  147. // Play good tune.
  148. //-----------------------------------------------------------
  149.  
  150. goodtone()
  151. {
  152. int n;
  153.   for (n=20; n < 200; n = 144*n/100) 
  154.   { tone(n*10,6);                        // Good tone!
  155.     terminal();                          // Process text.
  156.   }
  157. }
  158.  
  159. //-----------------------------------------------------------
  160. //  Trig loop. Waits here until either one "trig string" is
  161. //  found, or we have a time-out, or carrier is lost.
  162. //-----------------------------------------------------------
  163.  
  164. trig()
  165. {
  166. int i;
  167.   do
  168.   { terminal();
  169.   }  while (!time_up (tmark)             // Loop until time-out
  170.           && carrier()                   // or carrier lost
  171.           && (i=track_hit(0))==0);       // or we trigged.
  172.   if (i==0) 
  173.     i = -1;                              // Error!
  174.   else
  175.     timer_restart (tmark,tol);           // Restore timer.
  176.   return (i);
  177. }
  178.  
  179. //-----------------------------------------------------------
  180. // Free timer and tracking functions.
  181. //-----------------------------------------------------------
  182.  
  183. release()
  184. {
  185.   timer_free (tmark);                    // free timer channel
  186.   track_free (0);                        // and all track channels.
  187. }
  188.  
  189.  
  190. //-----------------------------------------------------------
  191. // Read a global variable.
  192. //-----------------------------------------------------------
  193.  
  194. read (str name, str varname)
  195. {
  196.   return (call (global,"R",name,varname));
  197. }
  198.  
  199. //-----------------------------------------------------------
  200. // Write a global variable.
  201. //-----------------------------------------------------------
  202.  
  203. write(str name, str varname)
  204.   return (call (global,"W",name,varname));
  205. }
  206.